package com.xinongbest.mall.controller;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class TestController {
    public static void main(String[] args) {
        String text = "This is a sample text containing some random email addresses like john.doe@example.com, jane@yahoo.com, and foo@bar.com.";
        text = "邮箱测试<wan>(wanzhijun@myhexin.com),<w>(wzj@myhexin.com)";
        Pattern pattern = Pattern.compile("\\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Z]{2,}\\b", Pattern.CASE_INSENSITIVE);
        Matcher matcher = pattern.matcher(text);
        while (matcher.find()) {
            System.out.println("Email found at index " + matcher.start() + ": " + matcher.group());
        }

    }
}